<template>
	<el-dialog title="" width="900px" visible :show-close="false" :append-to-body="true"  class="wrap">
		<i class="el-icon-close close" @click="cancel" style="color: white;"></i>
		<div class="bt">{{this.zwm}}-课程结转</div>
		<el-form label-width="100px" class="form">
			    	<div>
			    	<el-table :data="dataList" border stripe size='small' type="mini" align="center" class="admin-table" sum-text>
					<div slot='empty'>
						<img src="../../../assets/img/empty.png" style="width:40px;vertical-align: middle;">
						<span style="vertical-align: middle;">您还没有选择物品哦!</span>
					</div>
					<el-table-column :prop="v.prop" :label="v.label" v-for="(v,index) in portTitleList" align="center" show-overflow-tooltip v-if="v.hide != 0" :formatter="v.formatter" :align="v.align || 'center'" :fixed="v.fixed" :class-name="v.columnStyle" :width="v.width" :header-align="v.headerAlign || 'center'">
						<template scope="scope">
							<div slot="reference" :style="tableCellControl(scope)" v-if="scope.column.property === 'cnt'">
								<el-input class="content-input" type="number" v-model="scope.row[scope.column.property]"></el-input>
								<!-- :disabled="scope.row.type === '物品' && scope.column.property === 'zk' ? true:false" -->
							</div>
							<!--<div slot="reference" v-else-if=" scope.column.property == 'zk'">
								<el-input class="content-input" type="number" v-model="scope.row[scope.column.property]" @change="callzhi()"></el-input>
							</div>-->
							<!--<div slot="reference" v-else-if="scope.column.property === 'zj'">
								{{scope.row.jcjg * scope.row.cnt * scope.row.zk*1/100 || 0}}
							</div>-->
							<div slot="reference" v-else>
								{{ scope.row[scope.column.property] }}
							</div>
						</template>
					</el-table-column>

					<el-table-column label="操作" align="center" width="100px">
						<template scope="scope">
							<el-button size="small" type="warning" @click="componentsShow('jzxq',scope)" >去结转</el-button>
						</template>
					</el-table-column>
				</el-table>
		<JzxqComponent v-if="portComponents.jzxq.toggle" @close="componentsHide" :params="portComponents.jzxq.params" ></JzxqComponent>
				
				</div>
		</el-form>
	</el-dialog>
</template>
<script type="text/javascript">
	import qs from 'qs'
    import JzxqComponent from './jzxq'
	export default {
		props: ['params'],
		components: {
			JzxqComponent
		},
		data() {
			return {
				pickerOptions0: {
		          disabledDate(time) {
//		             return time.getTime() < Date.now() - 8.64e6   
		             return time.getTime() < Date.now() + 8.64e6      
		          }
		        },
		        dataList:[],
		        xsdataList:[],
		        activeName:'first',
				multipleDelNum: '',
            	multipleDeleteDisabled: true,
				comboxlist:[],
				xzlsList:[],
				ybjmc:'',
				form: {
					fxkcmc: '',
					mc: '',
					xsid:'',
					lsmc: '',
					lsid: '',
					xzid: '',
					cmc: '',
					jcmc: '',
					isqy: '',
					kcid: '',
					id: '',
					xzls: '',
					yjkbrq: '',
					kbsjd: '',
					note: '',
					xzlsmc: '',
					kss: '',
					jsid: '',
					kccnt: '',
					bjid:'1',
					
				},
				/*分页属性设置*/
				layout: 'total, sizes, prev, pager, next, jumper', //组件布局
				pageindex: 1, //当前分页页码
				pagesizes: [6], //显示个数的选择器选项
				pagesize: 6, //每页显示条目数
				total: 0, //总条数
				/*组件区域*/
                portComponents: {
                    jzxq: {
                        type: 'jzxq',
                        toggle: false,
                        params: '',
                        data: {}
                    }
                },
				portTitleList: [{
						prop: 'id',
						label: 'id',
						hide: 0,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center'
					},
					{
						prop: 'orderid',
						label: 'orderid',
						hide: 0,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '100',
						headerAlign: 'center'
					},
					{
						prop: 'xsid',
						label: 'xsid',
						hide: 0,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '100',
						headerAlign: 'center'
					},
					{
						prop: 'fxkcid',
						label: '课程id',
						hide: 0,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '100',
						headerAlign: 'center'
					},
					{
						prop: 'zwm',
						label: '中文名',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '100',
						headerAlign: 'center'
					},
					{
						prop: 'mc',
						label: '课程名称',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '100',
						headerAlign: 'center'
					},
					{
						prop: 'jcjg',
						label: '基础价格',
						hide: 0,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '100',
						headerAlign: 'center'
					},
					{
						prop: 'zkjcjg',
						label: '折扣基础价格',
						hide: 0,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '100',
						headerAlign: 'center'
					},
					{
						prop: 'cns',
						label: '购买课时',
						hide: 0,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '100',
						headerAlign: 'center'
					},
					{
						prop: 'ysks',
						label: '已上课时',
						hide: 0,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '100',
						headerAlign: 'center'
					},
					{
						prop: 'syks',
						label: '剩余课时',
						hide: 0,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '100',
						headerAlign: 'center'
					},
					{
						prop: 'zk',
						label: '折扣',
						hide: 0,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '100',
						headerAlign: 'center'
					},
					{
						prop: 'sj',
						label: '购买时间',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '100',
						headerAlign: 'center'
					},
					{
						prop: 'zfje',
						label: '支付金额',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '100',
						headerAlign: 'center'
					},
				],
				
				// 分页
//				layout: 'total, sizes, prev, pager, next, jumper', //组件布局
//				pageindex: this.$store.state.pageindex, //当前分页页码
//				pagesizes: this.$store.state.pagesizes, //显示个数的选择器选项
//				pagesize: this.$store.state.pagesize, //每页显示条目数
//				total: 0, //总条数
			}
		},
		created() {
			console.log(this.params,'kkkkkkkkkkk')
			if(this.$route.query.ysj == 'ysj') {
				this.form.id = this.$route.query.iid
				this.ybjmc = this.$route.query.bjmc
			}
			if(this.params) {
					this.form.id = this.params.bjid;
					this.form.xsid = this.params.row.xsid;
					this.ybjmc = this.params.bjmc;
					this.zwm = this.params.row.zwm;
			}
			if(this.params.row) {
					this.form.xsid = this.params.row.id;
			} 
			this.getjslist();
			this.kclist();
		},

		methods: {
			kclist() {
//				alert(this.form.xsid)
				var logininfo = JSON.parse(localStorage.logininfo);
				this.searchLoading = true;
				var params2 = qs.stringify({
					xsid: this.form.xsid+'',
					yhid: logininfo.id,
					xxid: logininfo.xxid
				})
				//执行
				this.axios.post(this.$store.state.api + 'order/getxskc', params2)
					.then(res => {
						console.log(res, 'ffff')
						this.dataList = res.data.data.list;
					}).catch(res => {})
			},
			tableCellControl(scope) { //表格单元格控制CSS样式
				// console.log(scope)
				/*if (scope.row.id == 112 && scope.column.property == "iname") {
				    return {
				        color:"red",
				    }
				}else{
				    return {
				        color:"green",
				    }
				}*/
			},
			callzhi(strvalue) {
				for(let i in this.dataList) {
					var o = this.dataList[i];
					if(o.zk > 100) {
						o.zk = 100
						this.$message.error('输入的折扣不能大于100！');
					}
					if(o.zk < 0) {
						o.zk = 0
						this.$message.error('输入的折扣不能小于0！');
					}
				}
			},
			jz(scope) {
				console.log(scope,'ooooooooooo')
				this.$store.state.loading = true;
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
					    orderkcmxid: scope.row.id,
						lx:'2',
						yhid: logininfo.id,
						xxid: logininfo.xxid,
				});
				//执行
				this.axios.post(this.$store.state.api + 'ordermx/js', params3)
					.then(res => {
						console.log(res,'pppppppppp')
						if(res.data.code == 1) {
						this.$emit('close', { type: 'kcjz', cancel: false });
							this.$message.success(res.data.msg);
							this.$store.state.loading = false;
						} else {
							this.$message.warning(res.data.msg);
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.danger("服务器繁忙，请重试");
						this.$store.state.loading = false;
					})
			},
			checkSelect (selection, row) {//点击单选select触发事件
//				console.log(selection,'ggggggggggggg')
                this.multipleDelNum = selection
                if(this.multipleDelNum.length>0){
                	this.multipleDeleteDisabled = false
                }else{
                	this.multipleDeleteDisabled = true
                }
            },
            checkall (selection) {//点击全选select触发事件
                this.multipleDelNum = selection
                if(this.multipleDelNum.length>0){
                	this.multipleDeleteDisabled = false
                }else{
                	this.multipleDeleteDisabled = true
                }
            },
			bj() {
				var logininfo = JSON.parse(localStorage.logininfo);
				this.searchLoading = true;
				var params2 = qs.stringify({
					xxid: logininfo.xxid,
					yhid: logininfo.id,
					kcid: this.form.fxkcid
				})
				//执行
				this.axios.post(this.$store.state.api + 'bj/zdgetbjmc', params2)
					.then(res => {
						console.log(res)
						this.form.mc = res.data.data.list[0].bjmc;
						this.searchLoading = false;
					}).catch(res => {})

			},

			getjslist() {
				var logininfo = JSON.parse(localStorage.logininfo);
				var params2 = qs.stringify({
					xxid: logininfo.xxid
				})
				//执行
				this.axios.post(this.$store.state.api + 'xxjs/mc', params2)
					.then(res => {
//						console.log(res,'sssssssssssssssssssss')
						let data = res.data.data;
						this.jslist = data;
					}).catch(res => {})

			},
			everefbjlit() {
				Hub.$emit('change', 'hehe'); //Hub触发事件
			},
			baocun() {
				this.$store.state.loading = true;
				this.$store.state.loading = true;
				var time1 = this.$.getLocalTimeNo0(Date.parse(this.form.yjkbrq));
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
					kscnt: this.form.kscnt + '',
					fxkcid: this.form.fxkcid + '',
					kbrq: time1,
					xzid: this.form.xzid + '',
					jcid: this.form.jcid + '',
					lsid: this.form.lsid + '',
					mc: this.form.mc + '',
					id: this.form.bjid + '',
					note: this.form.note+'',
					yhid: logininfo.id + '',
					xxid: logininfo.xxid + ''
				});
				//执行
				this.axios.post(this.$store.state.api + 'bj/updateysjbj', params3)
					.then(res => {
						if(res.data.code == 1) {
//							this.$emit('close', {type: 'sj',cancel: false});
							this.$message.success("保存成功!");
						    this.bjddlist();
//							this.$store.state.loading = false;
						} else {
							this.$message.warning(res.data.msg);
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.danger("服务器繁忙，请重试");
						this.$store.state.loading = false;
					})
			},
			submit(type) {
				//装载数据
				var time1 = this.$.getLocalTimeNo0(Date.parse(this.form.yjkbrq));
				var logininfo = JSON.parse(localStorage.logininfo);
				var params2 = qs.stringify({
					kbsjd: time1 + '',
					kscnt: this.form.kscnt + '',
					yjkbrq: time1,
					jsid: this.form.jsid + '',
					sjdid: hstr + '',
					note: this.form.note + '',
					xzid: this.form.xzls + '',
					xxid: logininfo.xxid + '',
					fxkcid: this.form.fxkcid + '',
					jcid: this.form.jcid + '',
					cid: this.form.cid + '',
					lsid: this.form.lsid + '',
					mc: this.form.mc + '',
					id: this.form.id + '',
					yhid: logininfo.id + '',
				})
				// this.everefbjlit();
				//执行
				this.axios.post(this.$store.state.api + 'bj/updatebjsj', params2)
					.then(res => {
						if(type == 1) {
							if(res.data.code == 1) {
								this.$emit('close', {
									type: 'sj',
									cancel: false
								});
//							this.$store.state.loading = false;
							} else {
								this.$message.warning(res.data.msg);
							}
						} else {
							this.showjskblist = true;
							this.showjslskblist = true;
						}

					}).catch(res => {
						this.$message.warning("服务器异常");
					})
			},
			cancel() {
				
				if(this.$route.query.bjmc) {
					this.$emit('close', {
						type: 'kcjz',
						cancel: true
					})
//					this.$router.back(-1)
				} else {
					this.$emit('close', {
						type: 'kcjz',
						cancel: true
					})
				}
			},
			 componentsShow (type,data) { //显示组件
                for ( let i in this.portComponents ) {
                    if (type == this.portComponents[i].type) {
                        this.portComponents[i].toggle = true;
                        this.portComponents[i].params = data;
                        if (this.portComponents[i].data.type == 'single') {
                            this.portComponents[i].data.index = data.row.id
                        }else if(this.portComponents[i].data.type == 'multiple'){
                            this.portComponents[i].data.index = this.multipleDelNum;
                        }else{
                            return;
                        }
                        return;
                    }
                }
            },
            componentsHide (setting) { //关闭组件
                for ( let i in this.portComponents ) {
                    if (setting.type == this.portComponents[i].type) {
                        this.portComponents[i].toggle = false;
                        if (!setting.cancel) {
                           this.kclist();
                        }
                        return;
                    }
                }
            }

		}
	}
</script>
<style lang="less" scoped>
	.wrap {
		.row {
			height: 50px;
			line-height: 50px;
		}
		.kblistul{
			width: 90%;
			text-align: center;
			margin: 0 auto;
			border: 1px solid;
			overflow: hidden;
			li{
				width: 12.5%;
				height: 100px;
				border: 1px solid;
				float: left;
			}
		}
		.bt {
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top: 0;
			left: 0;
			// margin-top: -70px;
			background: #50BFFF;
			// margin-left: -20px;
			// margin-bottom: 20px;
			color: white;
			text-align: left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
		.jftop1 {
			width: 100%;
			height: 30px;
			overflow: hidden;
			input {
				width: 80px;
				text-align: center;
				border: none;
				outline: none;
				background: transparent;
				border-bottom: 1px solid #ccc;
			}
			.span1 {
				width: 70%;
				height: 100%;
				line-height: 30px;
				border: 1px solid #EBEEF5;
				border-bottom:none;
				float: left;
				padding-left: 20px;
			}
			.span2 {
				width: 20%;
				border: 1px solid #EBEEF5;
				height: 100%;
				line-height: 50px;
				float: left;
				padding-left: 20px;
			}
			.span3 {
				width: 10%;
				border: 1px solid #EBEEF5;
				height: 100%;
				line-height: 50px;
				float: left;
			}
		}
		.close {
			z-index: 10;
			position: absolute;
		}
		.input-block {
			margin-bottom: 20px;
			text-align: center;
		}
		.input {
			width: 280px;
			display: inline-block;
			margin-left: 10px;
		}
		.input1 {
			width: 210px;
			display: inline-block;
			margin-left: 10px;
		}
		.input-block span {
			display: inline-block;
			width: 70px;
			text-align: right;
		}
		.submit {
			width: 120px;
			// display: block;
			// margin: 0 auto;
		}
		.wpfl {
			background: #fff;
			position: absolute;
			top: 5px;
			left: 5px;
		}
		.wpfl1 {
			width: 100%;
			background: #fff;
			position: absolute;
			top: 5px;
			left: -66px;
		}
		.lskb {
			width: 120%;
			background: #fff;
			position: absolute;
			top: 5px;
			left: -66px;
			z-index: 50;
		}
		.form {
			text-align: left;
			margin-top: 10px;
			.zzz {
				width: 100%;
				height: 100%;
				overflow: hidden;
				.an {
					.en1 {
						text-align: left;
						width: 100%;
						padding-left: 30px;
					}
					.en2 {
						width: 100%;
						margin-top: 20px;
						height: 60px;
						margin-bottom: 10px;
						overflow: hidden;
						border-bottom: 1px solid #eee;
						.inp {
							width: 45%;
							float: left;
						}
						.inp2 {
							width: 45%;
							float: left;
							margin-left: 5%;
						}
					}
				}
			}
			.select-block {
				width: 85%;
				display: block;
			}
			.select-block1 {
				width: 63%;
				// display: block;
			}
			.zjselect-block {
				width: 20%;
				float: left;
				display: block;
			}
			.el-form-item {
				margin-bottom: 10px;
			}
			.weekdiv {
				width: 100%;
				height: 100%;
				margin: 0 auto;
				background: lightblue;
			}
			.wdiv0 {
				line-height: 45px;
				width: 110px;
				height: 300px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv1 {
				width: 50px;
				height: 300px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv2 {
				width: 50px;
				height: 300px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv3 {
				width: 50px;
				height: 300px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv4 {
				width: 50px;
				height: 300px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv5 {
				width: 50px;
				height: 300px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv6 {
				width: 50px;
				height: 300px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv7 {
				width: 50px;
				height: 300px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.el-checkbox+.el-checkbox {
				margin-left: 0px;
			}
		}
	}
</style>